#!/usr/bin/expect

# 设置程序超时时间
set timeout 3

# echo
# echo "1. 生成RSA密钥"
# echo "※请输入pass phrase的密码：123456"
spawn openssl genrsa -des3 -out private.pem 2048
send "123456\r"
send "123456\r"

# echo
# echo "2. 生成一个证书请求"
# echo "※Country Name: CN"
# echo "※State or Province Name: SHANGHAI"
# echo "※Locality Name: SHANGHAI"
# echo "※Organization Name: YUJIAWEI"
# echo "※Organizational Unit Name: YUJIAWEI"
# echo "※Common Name: YUJIAWEI"
# echo "※Email Address: 1341069918@qq.com"
# echo "※challenge password: 123456"
spawn openssl req -new -key private.pem -out csr.pem
send "123456\r"

send "CN\r"
send "SHANGHAI\r"
send "SHANGHAI\r"
send "YUJIAWEI\r"
send "YUJIAWEI\r"
send "YUJIAWEI\r"
send "1341069918@qq.com\r"
send "123456\r"

# echo
# echo "3. 创建crt文件"
# echo "※pass phrase: 123456"
spawn openssl x509 -req -days 365 -in csr.pem -signkey private.pem -out file.crt
send "123456\r"
interact
